/*
 * Copyright 2016-2019 yoara
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package yhao.infra.feature.payment;

import yhao.infra.feature.payment.core.alipaynew.AliPayService;
import yhao.infra.feature.payment.core.alipaynew.config.AliPayConfig;
import yhao.infra.feature.payment.core.wxpay.WeiXinPayService;
import yhao.infra.feature.payment.core.wxpay.config.WinXinConfig;

/**
 * 配置工厂
 *
 * @author yoara
 */
public class ConfigFactory {
    public static AliPayService makeAliPayService(
            String notify_url_pre, String return_url, String aliPay_gateWay,
            String seller_id, String app_id, String app_private_key, String ali_public_key,
            String time_out_express) {
        AliPayConfig config = AliPayConfig.generateConfig(notify_url_pre,
                return_url, aliPay_gateWay, seller_id, app_id,
                app_private_key, ali_public_key, time_out_express);
        AliPayService aliPayService = new AliPayService(config);
        return aliPayService;
    }

    public static WeiXinPayService makeWeiXinPayService(
            String app_id, String partner_id, String partner_key, String notify_url_pre,
            String wap_url, String wap_name, String uniform_order_url, String refund_url,
            String refund_query_url, String redirect_url, String credentials_name, String pay_query_url) throws Exception {
        WinXinConfig config = WinXinConfig.generateConfig(
                app_id, partner_id, partner_key,
                notify_url_pre, wap_url, wap_name,
                uniform_order_url, refund_url, refund_query_url,
                redirect_url, credentials_name, pay_query_url);
        WeiXinPayService weiXinPay = new WeiXinPayService(config);
        return weiXinPay;
    }
}
